package com.yx.china.project.api;

import com.yx.china.project.entities.Payment;
import com.yx.china.project.entities.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@Slf4j
public class OrderApi {

    @Resource
    private RestTemplate restTemplate;

    @PostMapping("/order/payment/create")
    public ResponseResult<Payment> create(Payment payment){
        return restTemplate.postForObject("http://127.0.0.1:8001/payment/create",payment,ResponseResult.class);
    }

    @GetMapping("/order/payment/get/{id}")
    public ResponseResult<Payment> getPayment(@PathVariable("id") Long id){
        return restTemplate.getForObject("http://127.0.0.1:8001/payment/get/"+id,ResponseResult.class);
    }
}
